%==========================================================================
%=  This file is part of the Sound Restoration Project
%=  (c) Copyright Industrial Mathematics Institute
%=                University of South Carolina, Department of Mathematics
%=  ALL RIGHTS RESERVED
%=
%=  Author: Borislav Karaivanov
%==========================================================================

%==========================================================================
% List of the files on which this procedure depends:
%
% getdrives.m
%
%==========================================================================

%==========================================================================
% The function "setUpFactoryPresets" sets up a  factory-presets project
% structure which holds generally reasonable preset values for the
% parameters used in the optical sound extraction.
% INPUT: None.
% OUTPUT: "projectStruct" returns the project structure of factory presets.
%==========================================================================
function projectStruct = setUpFactoryPresets()

% Other presets.
projectStruct.numFramesToLocateSoundTrack = 5;
projectStruct.workFile.indFieldLength = 6;
projectStruct.workFile.fileExt = 'pgm';
projectStruct.projIndFieldLength = 2;
projectStruct.projNamePrefixNoPath = 'project';
projectStruct.soundBoundsArr = [];
projectStruct.frameRate = 24;
projectStruct.logFileNameNoPath = 'log';
projectStruct.writeToLogFunctHandle = @(x) '';

% Directories presets.
if (ispc == true)
    % Get all drives currently mounted.
    drivesCellArr = getdrives('-nofloppy');
    % Find a drive where writing and reading is allowed and place the
    % scratch directories there.
    projectStruct.scratchDir1 = '';
    projectStruct.scratchDir2 = '';
    for k = 1:numel(drivesCellArr)
        [status, currAttrib] = fileattrib(drivesCellArr{k});
        if ( (status == 1)&&(currAttrib.UserRead == true)&&(currAttrib.UserWrite == true) )
            projectStruct.scratchDir1 = 'C:\Scratch\';
            projectStruct.scratchDir2 = 'C:\Scratch\';
            break;
        end
    end
else
	projectStruct.scratchDir1 = '/tmp/';
	projectStruct.scratchDir2 = '/tmp/';
end
projectStruct.isCleanScratchDirOn = false;
projectStruct.isCleanOutputDirOn = false;

% Rough sound extraction presets.
projectStruct.isRoughExtractionOn = true;
projectStruct.framesPerBatch = 200;
projectStruct.readingAttempts = 5;

% Finer sound extraction presets.
projectStruct.isFinerExtractionOn = false;
projectStruct.signalsPerMask = Inf;
projectStruct.framesForOverlapGuess = 400;
projectStruct.rowsToIgnore = 101;
projectStruct.rowsToIgnoreUnits.choicesCellArr = {'pixels'; '%'};
projectStruct.rowsToIgnoreUnits.currChoiceInd = 1;
projectStruct.initialSearchRadius = 10;
projectStruct.localSearchRadius = 5;
projectStruct.overlapThreshold = 5;
projectStruct.isMovingAverageOn = false;
projectStruct.sweeps = 1;
projectStruct.span = 15;
projectStruct.isPolynomialOn = true;
projectStruct.isDegree1On = true;
projectStruct.isDegree2On = true;
projectStruct.isDegree3On = true;
projectStruct.isDegree4On = true;

% Sound smoothing presets.
projectStruct.isSoundSmoothingOn = false;
projectStruct.smoothingSpan = 5;

% Log keeping presets.
projectStruct.isLogKeepingOn = false;

% Visual diagnostics presets.
projectStruct.isVisualDiagnosticsOn = false;

% Export presets.
projectStruct.exportOptions.choicesCellArr = {'video with audio'; 'audio only'; 'video only'; 'images and audio'};
projectStruct.exportOptions.currChoiceInd = 1;
projectStruct.isOpenInExternalPlayerOn = true;

% Audio presets.
projectStruct.maxAmplitude = 0.4;
projectStruct.bitDepth.choicesCellArr = {8; 16; 24; 32};
projectStruct.bitDepth.currChoiceInd = 2;
projectStruct.samplingRate.choicesCellArr = {'native'; '8kHz'; '16kHz'; '32kHz'; '44.1kHz'; '48kHz'; '96kHz'};
projectStruct.samplingRate.currChoiceInd = 6;

% Video presets.
projectStruct.frameOffset.choicesCellArr = {'+25 [16 mm]'; '+21 [theatrical standard]'; ...
    '+11 [all Movietone negative]'; '-14 [Phonofilm]'; 'custom ...'};
projectStruct.frameOffset.currChoiceInd = 1;
projectStruct.isOriginalVideoOn = false;
projectStruct.isVideoFromImagesOn = false;
projectStruct.isImagesOn = false;
projectStruct.isPreserveAspectRatioOn = false;
projectStruct.isMp4QualityOn = false;
projectStruct.mp4QualityPerc = 75;
projectStruct.isUncompressedOn = false;

return;
% end of the function "setUpFactoryPresets"
